<script>
  $(document).ready(function() {
	$(".subHead").on("click",function(event) {
		var titleName = $(this).attr("id");
		var divName = titleName.replace("Title","");
		
		if($("#" + divName).is(":visible")) {
			$("#" + divName).slideUp();
		}
		else {
			$("#" + divName).slideDown();
		}	
	});
	
	$(".expand").attr("title","Click to show or hide");
	
	
	var subRecall = $("#sub_recall").html();
	var unusual = $("#unusual").html();
	
	if(subRecall == "1") {
		$("#sub_recall").html("During Sighting");
	}
	else {
		$("#sub_recall").html("After Sighting");
	}
	
		if(unusual == "1") {
		$("#unusual").html("Is unusual");
	}
	else {
		$("#unusual").html("Not unusual");	
	}	
});
</script>

  <h1>View Submission</h1>
  <br>
  <span id="birdInfoTitle" class="subHead expand">Bird Information</span><span class="help">(Click title to show or hide this group)</span>
  <div class="subGroup" id="birdInfo">
  <br>
  <% if isadmin? %>
  <div class="subLabel">
		<span>Observer</span>
		<%= link_to @submission.user.name, @submission.user%>
		</div>
	<br>
	<div class="subLabel">
		<span>Observer Email</span>
		<span style="color:white;">
		<%= mail_to @submission.user.email %>
		
		</span>
	</div>
	<br>
	<% end %>
  	<div class="subLabel">
		<span>Common Bird Name</span>
		<%= @submission.bird.common_name %>
		<% if @submission.bird_id == 31 %>
		(<%= @submission.common_name %>)
		<% end %>
		
	</div>
	<br>
	<div class="subLabel">
		<span>Number of Birds</span>
		<%= @submission.num_of_birds %>
	</div>
	<br>
	<div class="subLabel">
		<span>Age of Bird(s)</span>
		<%= @submission.age %>
	</div>
	<br>
	<div class="subLabel">
		<span>Sex of Bird(s)</span>
		<%= @submission.sex %>
	</div>
	<br>
	<div class="subLabel">
		<span style="position.relative; bottom.90px;">General Plumage (Breeding, nonbreeding, etc.)</span>
		<%= @submission.plumage%>
	</div>
	<br>
	<div class="subLabel">
		<span style="position.relative; bottom.90px;">Detailed Description of Bird</span>
		<%= simple_format(@submission.detailed_description) %>
	</div>
	<br>
	<div class="subLabel">
		<span style="position.relative; bottom.90px;">Detailed Behavior of Bird (Flight pattern, feeding, etc.)</span>
		<%= simple_format(@submission.detailed_behavior) %>
	</div>
	<br>
	<div class="subLabel">
		<span style="position.relative; bottom.70px;">Distinguishing Characteristics From Other Species</span>
		<%= simple_format(@submission.distinguished_char) %>
	</div>
	<br>
	<div class="subLabel">
		<span >Bird Habitat Description</span>
		<%= simple_format(@submission.habitat)%>
	</div>
  </div>
  
  <br><br>
  
  <span id="subInfoTitle" class="subHead expand">Submission Information</span><span class="help">(Click title to show or hide this group)</span>
  <div class="subGroup" id="subInfo">
	<br>
	<div class="subLabel">
		<span>Reporting Observers</span>
		<%= @submission.coobservers %>
	</div>
	<br>
	<div class="subLabel">
		<span>Location</span>
		<%= @submission.location %>
	</div>
	<br>
	<div class="subLabel">
		<span>GPS Coordinates</span>
		<%= @submission.gps %>
	</div>
	<br>
	<div class="subLabel">
		<span>Sighting Date and Time</span>
		<%= @submission.sight_date_time.strftime("%m/%d/%y  %I:%M%p") %>
	</div>
	<br>
	<div class="subLabel">
		<span>Length of Observation</span>
		<%= @submission.length_of_obs %>
	</div>
	<br>
	<div class="subLabel">
		<span>Distance from Bird</span>
		<%= @submission.distance_from %>
	</div>
	<br>
	<div class="subLabel">
		<span >Optical Equipment Used</span>
		<%= simple_format(@submission.optical_equipment)%>
	</div>
	<br>
	<div class="subLabel">
		<span >References Used</span>
		<%= simple_format(@submission.references)%>
	</div>
	<br>
	<div class="subLabel">
		<span>Submission Made</span>
		<span id="sub_recall"><%= @submission.sub_recall %></span>
	</div>
	<br>
	<div class="subLabel">
		<span>Is an Unusual Sighting</span>
		<span id="unusual"><%= @submission.unusual.titleize %></span>
	</div>
	<br>
	<div class="subLabel">
		<span >Field Guide Used</span>
		<%= simple_format(@submission.guide_use) %>
	</div>
	<br>
	<div class="subLabel">
		<span >Previous Experience with this Bird</span>
		<%= simple_format(@submission.prev_bird_exp)%>
	</div>
	<br>
	<div class="subLabel">
		<span >Notes</span>
		<%= simple_format(@submission.notes)%>
	</div>
	<br>
	<div class="subLabel">
		<span>Multimedia</span>
		<%  @multimedia.each do |multimedium| %>
			<%= link_to image_tag(multimedium.image_url(:thumb)), multimedium.image_url.to_s if multimedium.image?%>
			<%= link_to image_tag("video.png", :size => "100x100"), multimedium.video_url.to_s if multimedium.video?%>
			<%= link_to image_tag("audio.png", :size => "100x100"), multimedium.audio_url.to_s if multimedium.audio?%>
		<% end %>
	</div>	
  </div>
  
   <br><br>
  
  <% if isadmin? %>
  <span id="adminInfoTitle" class="subHead expand">Administrator Information</span><span class="help">(Click title to show or hide this group)</span>
  <div class="subGroup" id="adminInfo">
  <br>
	<div class="subLabel">
		<span >Working Notes</span>
		<%= simple_format(@submission.working_notes) %>
	</div>
	<br>
	<div class="subLabel">
		<span>Administrator Notes</span>
		<%= @submission.admin_notes %>
	</div>
	<br>
	<div class="subLabel">
		<span>Category of Acceptance</span>
		<%= @submission.s_degree %>
	</div>
	<br>
	<div class="subLabel">
		<span>Region</span>
		<%= @submission.region %>
	</div>
	<br>
	<div class="subLabel">
		<span>Voting Date</span>
		<%= @submission.date_votable.strftime("%m/%d/%y  %I:%M%p") if @submission.date_votable %>
	</div>
	<br>
	<div class="subLabel">
		<span>Submission Status</span>
		<%= @submission.status.humanize %>
	</div>
	<br>
	<div class="subLabel">
		<span>Round</span>
		<%= @submission.rounds %>
	</div>
  </div>
  <% end %>
  

<% if (isadmin? || isreviewer?) && (!@hasVoted) %>
	<%= render :partial => 'votes/form' if isreviewer?%>
	<%= render :partial => 'votes/list' if isadmin? %>
<% end %>
	<br/><br>
	<% if @submission.user_authorized_to_edit?(session[:user]) %>
<%= button_to 'Edit', edit_submission_path(@submission), :class=>'btn-custom', :form_class=>'inline' %>
<% end %>   

	<% if @submission.user_authorized_to_edit?(session[:user]) %>
<%= button_to 'Destroy', @submission, :class=>'btn-custom', :form_class=>'inline', :confirm => "Are you sure?", method: :delete  %><% end %>
<br/>
<%= link_to 'Submission List', submissions_path%>